package org.wk.user.dao;

import org.springframework.data.jpa.repository.Query;
import org.wk.core.db.dao.GenericJpaRepository;
import org.wk.user.domain.ApplyVip;

import java.util.List;

public interface ApplyVipDao extends GenericJpaRepository<ApplyVip,String> {
    // 通过用户ID查询申请记录
    ApplyVip findByUserIdAndVerifyStatusCode(String userId, String verifyStatusCode);

    /**
     * 查询正在申请或者审核中的信息
     * @param userId
     * @param status
     * @return
     */
    @Query(nativeQuery = true,value = "SELECT * from s_user_applyforvip where user_id = ?1 and (relation_status = ?2 or seller_status = ?2)")
    ApplyVip findByUserIdAndVerifyStatus(String userId, String status);

    //根据申请人查询申请列表
    List<ApplyVip> findByRelationIdAndRelationStatus(String relationId, String relationStatus);

    //根据二号申请人(商家)查询申请列表
    List<ApplyVip> findBySellerIdAndSellerStatus(String sellerId, String sellerStatus);

    //根据申请人与被申请人id查询列表
    ApplyVip findByUserIdAndRelationId(String userId, String relationId);

    //根据申请人与被申请商家id查询列表
    ApplyVip findByUserIdAndSellerId(String userId, String sellerId);


}
